package _interview150;

/**
 * 191. 位1的个数
 */
public class No191 {
    public int hammingWeight(int n) {
        int ans = 0;
        for (int i = 0; i < 32; i++) {
            ans += (1 << i & n) == 0 ? 0 : 1;
        }
        return ans;
    }
}
